<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="../css/base.css">
    <link rel="stylesheet" href="../css/选项卡2.css">
</head>

<body>
    <div id="box">
        <div class="nav">
            <input type="button" value="精选" class="act">
            <input type="button" value="社会">
            <input type="button" value="娱乐">
            <input type="button" value="生活">
            <input type="button" value="体育">
        </div>
        <div class="list">
            <section class="pic">
                <img src="../images/pic.png" alt="">
            </section>
            <ul class="news">
                <li>
                    <span>香港乱了北京该不该强力出手”</span>
                    <span>热点</span>
                </li>
                <li>
                    <span>香港乱了北京该不该强力出手”</span>
                    <span>热点</span>
                </li>
                <li>
                    <span>香港乱了北京该不该强力出手”</span>
                    <span>热点</span>
                </li>
                <li>
                    <span>香港乱了北京该不该强力出手”</span>
                    <span>热点</span>
                </li>
                <li>
                    <span>香港乱了北京该不该强力出手”</span>
                    <span>热点</span>
                </li>
                <li>
                    <span>香港乱了北京该不该强力出手”</span>
                    <span>热点</span>
                </li>
            </ul>
        </div>
        <div class="list">
            <section class="pic">
                <img src="../images/pic.png" alt="">
            </section>
            <ul class="news">
                <li>
                    <span>世界500强企业中国终于超过美国</span>
                    <span>经济</span>
                </li>
                <li>
                    <span>世界500强企业中国终于超过美国</span>
                    <span>经济</span>
                </li>
                <li>
                    <span>世界500强企业中国终于超过美国</span>
                    <span>经济</span>
                </li>
                <li>
                    <span>世界500强企业中国终于超过美国</span>
                    <span>经济</span>
                </li>
                <li>
                    <span>世界500强企业中国终于超过美国</span>
                    <span>经济</span>
                </li>
                <li>
                    <span>世界500强企业中国终于超过美国</span>
                    <span>经济</span>
                </li>
            </ul>
        </div>
        <div class="list">
            <section class="pic">
                <img src="../images/pic.png" alt="">
            </section>
            <ul class="news">
                <li>
                    <span>霍顿不与孙杨合影遘英国媒体炮轰</span>
                    <span>体育</span>
                </li>
                <li>
                    <span>霍顿不与孙杨合影遘英国媒体炮轰</span>
                    <span>体育</span>
                </li>
                <li>
                    <span>霍顿不与孙杨合影遘英国媒体炮轰</span>
                    <span>体育</span>
                </li>
                <li>
                    <span>霍顿不与孙杨合影遘英国媒体炮轰</span>
                    <span>体育</span>
                </li>
                <li>
                    <span>霍顿不与孙杨合影遘英国媒体炮轰</span>
                    <span>体育</span>
                </li>
                <li>
                    <span>霍顿不与孙杨合影遘英国媒体炮轰</span>
                    <span>体育</span>
                </li>
            </ul>
        </div>
        <div class="list">
            <section class="pic">
                <img src="../images/pic.png" alt="">
            </section>
            <ul class="news">
                <li>
                    <span>得知行凶者患精神病任达华不追究</span>
                    <span>新闻</span>
                </li>
                <li>
                    <span>得知行凶者患精神病任达华不追究</span>
                    <span>新闻</span>
                </li>
                <li>
                    <span>得知行凶者患精神病任达华不追究</span>
                    <span>新闻</span>
                </li>
                <li>
                    <span>得知行凶者患精神病任达华不追究</span>
                    <span>新闻</span>
                </li>
                <li>
                    <span>得知行凶者患精神病任达华不追究</span>
                    <span>新闻</span>
                </li>
                <li>
                    <span>得知行凶者患精神病任达华不追究</span>
                    <span>新闻</span>
                </li>
            </ul>
        </div>
        <div class="list">
            <section class="pic">
                <img src="../images/pic.png" alt="">
            </section>
            <ul class="news">
                <li>
                    <span>阿波罗宇航员登月曾寻找嫦娥玉兔</span>
                    <span>资讯</span>
                </li>
                <li>
                    <span>阿波罗宇航员登月曾寻找嫦娥玉兔</span>
                    <span>资讯</span>
                </li>
                <li>
                    <span>阿波罗宇航员登月曾寻找嫦娥玉兔</span>
                    <span>资讯</span>
                </li>
                <li>
                    <span>阿波罗宇航员登月曾寻找嫦娥玉兔</span>
                    <span>资讯</span>
                </li>
                <li>
                    <span>阿波罗宇航员登月曾寻找嫦娥玉兔</span>
                    <span>资讯</span>
                </li>
                <li>
                    <span>阿波罗宇航员登月曾寻找嫦娥玉兔</span>
                    <span>资讯</span>
                </li>
            </ul>
        </div>
    </div>
</body>
<script>
    (function(){
        //绑定节点，一般为整个盒子，需要执行事件部分，以及内容展示区域；
            var box = document.getElementById('box');
            var btn = box.getElementsByTagName('input');
            var con = box.getElementsByClassName('list');
            for(var i = 0;i < btn.length; i++){//遍历所有的按钮，运用循环
                btn[i].index = i;//绑定索引，用于后面的内容和按钮的绑定
                btn[i].onmousemove = function(){//对当前的按钮进行事件触发
                    for(var j = 0;j < btn.length; j++){
                        btn[j].className = '';
                        con[j].style.display = 'none';
                    }
                    this.className = 'act';//用this来指向对应按钮
                    con[this.index].style.display = 'block';
                }
            }
        }
    )()
</script>

</html>